package com.ihisomp.util;

import org.jasypt.util.text.BasicTextEncryptor;

/**
 * 标题: DataBaseTextEncryptor.java
 * 业务描述: 数据库配置文件加密
 * 作者: zy
 * 日期: 2022/9/7
 * 版本: V1.0
 */
public class DataBaseTextEncryptor {

    /**
     * 密码生成方法
     * @param args
     */
    public static void main(String[] args) {
        // 加密
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
        // 自己设置的秘钥
        textEncryptor.setPassword("Mediway@2022");
        // 数据加密
        String userName = textEncryptor.encrypt("root");
        System.out.println(userName);
        System.out.println("--------------------------");
        // 解密
        BasicTextEncryptor textEncryptor2 = new BasicTextEncryptor();
        textEncryptor2.setPassword("Mediway@2022");
        String oldPassword = textEncryptor2.decrypt("L6OtP8DxDAN0T85tLeZDEw==");
        System.out.println(oldPassword);
        System.out.println("--------------------------");
    }
}
